tools/libs/*: Use O_CLOEXEC on Linux and FreeBSD
authorIan Campbell <ian.campbell@citrix.com>
Wed, 2 Dec 2015 16:21:41 +0000 (16:21 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 22 Jan 2016 12:24:22 +0000 (12:24 +0000)
commit0831774c8188584e2a48a7c8070d56ba744ca279
treee42f9e88e99135673fef85528e334b0fa577d23b
parent0bd2a73ef234ce28dda1e990de2724a36765ec6e
tools/libs/*: Use O_CLOEXEC on Linux and FreeBSD

In some cases this replaces an FD_CLOEXEC dance, in others it is new.

Linux has had O_CLOEXEC since 2.6.23 (October 2007), so we can rely on
it from Xen 4.7 I think. Some libc headers may still lack the
definition, so we take care of that if need be by defining to 0 (on
the premise that such an old glibc might barf on O_CLOEXEC even if the
kernel may or may not be so old).

All stable versions of FreeBSD support O_CLOEXEC (10.2, 9.3 and 8.4),
and we assume the libc there does too.

Remove various comments about having to take responsibility for this
(since really it is just hygiene, politeness, not a requirement) and
the reasons for using O_CLOEXEC seem pretty straightforward.

Backends for other OSes are untouched.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Cc: Roger.Pau@citrix.com
Cc: jbeulich@suse.com
tools/libs/call/freebsd.c
tools/libs/call/linux.c
tools/libs/evtchn/freebsd.c
tools/libs/evtchn/linux.c
tools/libs/foreignmemory/freebsd.c
tools/libs/foreignmemory/linux.c
tools/libs/gnttab/linux.c